﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.SceneManagement;

public class Peter_InteractiveObj : MonoBehaviour
{


    public bool isSceneLoader = false;
    [SerializeField]
    private int index;
    public bool isInfo = false;
    public GameObject information;
    public AudioClip click;
    private AudioSource ppp;
    private Animator ddd;
    public GameObject otherObj;
    private Animator ccc;
    private SpriteRenderer thisInfo;
    private SpriteRenderer otherInfo;

    public string name= "aa";

    // Update is called once per frame
    void Start()
    {
        ppp = this.GetComponent<AudioSource>();
        ddd = otherObj.GetComponent<Animator>();
        ccc = information.GetComponent<Animator>();
        thisInfo = information.GetComponent<SpriteRenderer>();
        otherInfo = otherObj.GetComponent<SpriteRenderer>();
    }

    public void hovered()
    {
        if (isSceneLoader)
        {
            transform.localScale = Vector3.one * 1.20f;
        }
    }


    public void activated()
    {
        if (isSceneLoader)
        {
            SceneManager.LoadScene(index);
        }
        if (isInfo)
        {
            information.SetActive(true);
            thisInfo.enabled = true;
            otherInfo.enabled = false;
            ppp.clip = click;
            /*if (information != null)
            {
                Instantiate(information);
                Destroy(otherObj);
            }*/
        }
        else
        {
            information = null;
        }
    }



    public void leave()
    {
        if (isSceneLoader)
        {
            transform.localScale = Vector3.one;
        }
    }
}
